package com.zzptc.zzsgz.bdsjws.fragments.base;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.zzptc.zzsgz.bdsjws.MyApplication;
import com.zzptc.zzsgz.bdsjws.R;
import com.zzptc.zzsgz.bdsjws.activities.AddContactsActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2017/5/27.
 */

public class SecondFragment extends BaseFragmentbase {

    @BindView(R.id.et_add)
    EditText etAdd;

    @BindView(R.id.ing_add)
    ImageView ingAdd;

    @BindView(R.id.btn_yes)
    Button btnYes;
    Unbinder unbinder;


    @Override
    public int getXml() {
        return R.layout.secondfragment;
    }

    @Override
    public void initView() {
        EditText editText= (EditText) getThisView().findViewById(R.id.et_add);
        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                btnYes.setVisibility(View.GONE);
                ingAdd.setVisibility(View.VISIBLE);
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
    }

    @Override
    public void initData() {

    }




    @OnClick(R.id.ing_add)
    public void onViewClicked() {
        startActivity(new Intent(MyApplication.getContext(), AddContactsActivity.class));
    }

    @OnClick(R.id.btn_yes)
    public void onYesClicked() {
        //先判断电话号码的长度 并要获取电话号码
        String tel = etAdd.getText().toString().trim();
        etAdd.setText("");
        btnYes.setVisibility((View.GONE));
        ingAdd.setVisibility(View.VISIBLE);

    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }


}
